package com.study.d7_collections;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Test {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        Collections.addAll(list,"哈哈","你好","666");
        System.out.println(list);

        //打乱顺序
        Collections.shuffle(list);
        System.out.println(list);

        List<Girl> list2 = new ArrayList<>();
        list2.add(new Girl("陈",'女',20,165.3));
        list2.add(new Girl("六",'女',22,155.3));
        list2.add(new Girl("流",'女',80,168.3));
        list2.add(new Girl("黄",'女',10,167.3));
        System.out.println(list2);
        //排序（girl实现comparable）
        Collections.sort(list2);
        System.out.println(list2);
        List<Girl> list3 = new ArrayList<>();
        list3.add(new Girl("陈",'女',20,165.3));
        list3.add(new Girl("六",'女',22,155.3));
        list3.add(new Girl("流",'女',80,168.3));
        list3.add(new Girl("黄",'女',10,167.3));
        //排序，直接new Comparator
        Collections.sort(list3, (o1,o2)-> Double.compare(o2.getHeight(),o1.getHeight()));
        System.out.println(list3);
    }
}
